Enable using cppyy with debug build of Python#56
Enable using cppyy with debug build of Python#56Vipul-Cariappa wants to merge 1 commit intowlav:masterfrom
Conversation
The changes here collects residual exceptions thrown by Python, before calling into Python C API.
|
I really don't think straight-up sprinkling |
Vipul-Cariappa
left a comment
There was a problem hiding this comment.
This is the explanation:
| } | ||
| } | ||
|
|
||
| PyErr_Clear(); // creation might have failed |
There was a problem hiding this comment.
This happens when meta_getattro fails. In my investigation, it failed for some special methods. And if the user does something like:
In [3]: cppyy.cppdef("""
...: namespace ns {}
...: """)
Out[3]: True
In [4]: gbl.ns.something = 1There was a problem hiding this comment.
Hmm, now that I think about this, in the above-mentioned cases, it should not be calling meta_getattro. I will need to cross-check this.
| Utility::AddToClass(pyclass, "__real_data", "data"); | ||
| PyErr_Clear(); // AddToClass might have failed for data |
There was a problem hiding this comment.
This failure is at
Line 224 in 221e52b
With
pyclass and "data" as arguments.I guess this is one of the errors that we should not clear/ignore. I will look into it.
| PyObject* argtypes = nullptr; | ||
| PyObject* ret = nullptr; | ||
| if ((argtypes = PyObject_GetAttrString(arg, "argtypes")) && (ret = PyObject_GetAttrString(arg, "restype"))) { |
There was a problem hiding this comment.
This is just a safer rewrite for the PyErr_Clear in line 582 below.
The first GetAttr fails, then in the second, Python's assert(!PyErr_Occurred()) fails.
| if (PySequence_Check(pyobject) && !PySequence_Size(pyobject)) | ||
| return 0; // PyObject_GetBuffer() crashes on some platforms for some zero-sized seqeunces | ||
| PyErr_Clear(); |
There was a problem hiding this comment.
This happens when PySequence_Size fails with an error something like "sequence does not have __len__", but PySequence_Check succeeds. (I will cross-check, once)
The changes here collects residual exceptions thrown by Python, before calling into Python C API.
Reference: root-project/root#19239